    /**
     * @param {String} RequestWay >>>URl请求方式
     * @param {String} url >>>URl请求路径
     * @param {Object} data	>>>发送参数
     * @param {Boolean} async	>>>同步还是异步 默认为异步
     *	Ajax('post','http://60.10.165.110:8001/fbjd/msg/weather',{city:101090608})
     */
    function Ajax(RequestWay = 'POST', url, data, async = true){
        let xhr;
        if(window.XMLHttpRequest) {
            xhr = new XMLHttpRequest() || new ActiveXObject("Microsoft.XMLHTTP");
        }
        if (RequestWay === 'POST' || RequestWay === 'post') {
            xhr.open("POST", url, async);
            /*#可在此位置设置请求头根据业务配置*/
            /*Content-type (几种常见的Content-Type类型)
            application/x-www-form-urlencoded
            multipart/form-data
            application/json
            text/xml
			application/json;charset=UTF-8
            */
            xhr.setRequestHeader("Content-type", "application/json;charset=UTF-8");
            /*toke设置*/
            /*xhr.setRequestHeader("toke", "123");*/
        } else {
            /*#可在此位置设置请求头根据业务配置*/
            xhr.open("GET", url, async);
        }
        /*设置请求超时时间*/
		if(xhr && xhr.timeout) {
			xhr.timeout = 3000;
			xhr.ontimeout = function () { /*请求超时触发的事件*/
			    alert('请求超时!')
			};
		} 
       
        xhr.send(JSON.stringify(data));
    //     xhr.onload = function (e) {  /*加载*/
    //       if (xhr.readyState === 4) {
    //         if (xhr.status === 200) {
				// // btoa(xhr.responseText)
				// window.btoa(xhr.responseText)
    //           // console.log(xhr.responseText);
    //         } else {
    //           console.error(xhr.statusText);
    //         }
    //       }
    //     };
        xhr.onerror = function (e) { /*失败*/
          console.error(xhr.statusText);
        };
        xhr.onreadystatechange = function () {
            if(xhr.readyState <= 4 && xhr.status === 200) {
                //数据返回 根据业务做统一数据处理
                // let data = JSON.parse(xhr.responseText);
                // switch (data.conde) {
                // 	 case 200:
                // 	 return data;
                // 	 case 400:
                // 	 return false;
                // 	 default:
                //   return false;
                // }
				// window.btoa(xhr.responseText)
				window.encodeURIComponent(xhr.responseText)
                console.log(JSON.parse(xhr.responseText))
                // return JSON.parse(xhr.responseText);
            } else {
                console.error(`http状态码:${xhr.readyState}`);
                return false;
            }
        }
    }

  /**
   * 对象去重
   */
 function deteleObject (obj) {
    var uniques = []
    var stringify = {}
    for (var i = 0; i < obj.length; i++) {
      var keys = Object.keys(obj[i])
      keys.sort(function (a, b) {
        return (Number(a) - Number(b))
      })
      var str = ''
      for (var j = 0; j < keys.length; j++) {
        str += JSON.stringify(keys[j])
        str += JSON.stringify(obj[i][keys[j]])
      }
      if (!stringify.hasOwnProperty(str)) {
        uniques.push(obj[i])
        stringify[str] = true
      }
    }
    return uniques
  };

  // 获取本周1-7的年月日
 function WeekTime () {
    var newDate = new Date()
    var timesStamp = newDate.getTime() // 时间戳
    var currenDay = newDate.getDay()
    var dates = []
    for (var i = 0; i < 7; i++) {
      dates.push(new Date(timesStamp + 24 * 60 * 60 * 1000 * (i - (currenDay + 6) % 7)).toLocaleDateString().replace(
        /[年月]/g, '-').replace(/[日上下午]/g, ''))
    }
    return dates
  }

  /**
   * 获取本周一 的时间
    */
 function Monday () {
    var now = new Date()
    var nowTime = now.getTime()
    var day = now.getDay()
    var oneDayTime = 24 * 60 * 60 * 1000
    var MondayTime = nowTime - (day - 1) * oneDayTime // 显示周一
    // var SundayTime =  nowTime + (7-day)*oneDayTime ;//显示周日
    function p (s) {
      return s < 10 ? '0' + s : s
    };
    const d = new Date(MondayTime)
    const begintime = String(d.getFullYear()) + String(p((d.getMonth() + 1))) + String(p(d.getDate())) + '000000'
    return begintime
  };
  /**
   * 获取本周日 的时间
   */
 function Sunday () { // 本周日的日期
    var now = new Date()
    var nowTime = now.getTime()
    var day = now.getDay()
    var oneDayTime = 24 * 60 * 60 * 1000
    // var MondayTime = nowTime - (day - 1) * oneDayTime // 显示周一
    var SundayTime = nowTime + (7 - day) * oneDayTime // 显示周日
    function p (s) {
      return s < 10 ? '0' + s : s
    };
    const d = new Date(SundayTime)
    // const resTime = p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds());
    const resDate = String(d.getFullYear()) + String(p((d.getMonth() + 1))) + String(p(d.getDate())) + '235959' // 当前周的周末
    return resDate
  };
  /**
   * 获取本月的第一天
   */
 function getCurrentMonthFirst () {
    var date = new Date()
    date.setDate(1)
    var month = String(date.getMonth() + 1)
    var day = date.getDate()
    if (month <= 9) {
      month = '0' + month
    }
    if (day <= 9) {
      day = '0' + day
    }
    return String(date.getFullYear()) + String(month) + String(day) + '000000'
  };
  /**
   * 获取本月的最后一天
   */
 function getCurrentMonthLast () {
    var mydate = new Date()
    var currentMonth = mydate.getMonth()
    var nextMonth = ++currentMonth
    var nextMonthFirstDay = new Date(mydate.getFullYear(), nextMonth, 1)
    var oneDay = 1000 * 60 * 60 * 24
    var lastTime = new Date(nextMonthFirstDay - oneDay)
    var month = parseInt(lastTime.getMonth() + 1)
    var day = lastTime.getDate()
    if (month < 10) {
      month = '0' + month
    }
    if (day < 10) {
      day = '0' + day
    }
    var date = new Date(String(mydate.getFullYear()) + '-' + String(month) + '-' + String(day))
    if ((date.getMonth() + 1) <= 9) {
      var yue = '0' + (date.getMonth() + 1)
    } else {
      yue = (date.getMonth() + 1)
    }
    let dateValue = String(date.getFullYear()) + String(yue) + String(date.getDate()) + '235959'
    return dateValue
  };
  // 获取当前年月日
 function getNowFormatDate () {
    var date = new Date()
    var seperator1 = '-'
    var year = date.getFullYear()
    var month = date.getMonth() + 1
    var strDate = date.getDate()
    if (month >= 1 && month <= 9) {
      month = '0' + month
    }
    if (strDate >= 0 && strDate <= 9) {
      strDate = '0' + strDate
    }
    var currentdate = String(year) + String(seperator1) + String(month) + String(seperator1) + String(strDate)
    return currentdate
  };

  /**
   * 计算经纬度差值
   * @param {我当前经度} lat1
   * @param {我当前纬度} lng1
   * @param {企业的经度} lat2
   * @param {企业的纬度} lng2
   */
 function positionToCalculate (lat1, lng1, lat2, lng2) {
    function Rad (d) {
      return (d * Math.PI) / 180.0 // 经纬度转换成三角函数中度分表形式。
    }
    let radLat1 = Rad(lat1)
    let radLat2 = Rad(lat2)
    let a = radLat1 - radLat2
    let b = Rad(lng1) - Rad(lng2)
    let s = 2 * Math.asin(
      Math.sqrt(
        Math.pow(Math.sin(a / 2), 2) +
        Math.cos(radLat1) *
        Math.cos(radLat2) *
        Math.pow(Math.sin(b / 2), 2)))
    s = s * 6378.137 // EARTH_RADIUS;
    s = Math.round(s * 1000) / 1000 // 这里输出米   //输出为公里为 1Math.round(s * 10000) / 10000;
    let result = s.toString().split('.')
    // 位置完全相同
    if (result == 0) {
      return result[0]
    } else if (result[0] != 0) { // 当前距离大于一公里
      return null
    }
    return result[1] // 返回当前距离的米
  };
  /**
   * 用来返回当前枚举的
   * @param {数组} arr
   * @param {值} value
   */
	function transition (arr, value) {
    for (let s in arr) {
      if (arr[s].value == value) {
        return arr[s].label
      }
    }
  }

  /**
   * 传入数组返回出现次数最对的值
   * @param {arr} arrlist
   */

 function much (arrlist) {
    const d = {}
    arrlist.forEach(k => !d[k] ? d[k] = 1 : d[k]++)
    const max = Object.keys(d).sort((a, b) => d[b] - d[a])[0]
    return max
  };
  /**
   * 获取当前设备类型
   * 不传入阐述就返回PC端 || 移动端
   * 传入参数为移动端设备类型
   */
 function terminalEquipment (type = null) {
    let userAgentInfo = navigator.userAgent
    let Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod']
    if (type) {
      for (let v = 0; v < Agents.length; v++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) {
          var flag = Agents[v]
          break
        }
      }
      return flag
    } else {
      let flag = 'PC端'
      for (let v = 0; v < Agents.length; v++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) {
          flag = '移动端'
          break
        }
      }
      return flag
    }
  }


 /**
  * @description  传入的参数 都被 格式化base64格式进行存储
  * @return { string } 返回数据已被解析为原有的值
   *sessionStorage 页面关闭时清楚数据
   * @param {存储的到sessionStorage的名} key
   * @param {存储的到sessionStorage的数据} data
   * ===========使用前先要实例化
   * let se =  new session()
   * se.removeAll()
   */
function session (name) {
	this.w = window;
	this.sess =	name === undefined ? this.w.sessionStorage : this.w.localStorage
}
/**
 * @param {strng} key 存储的key值
 * @param {strng} value 存储的value值
 */
session.prototype.set = function (key , value) {
	// try{
	// 	key && value && this.sess.setItem(this.w.btoa(key),this.w.btoa(value))
	// }catch(e){		
		key && value && this.sess.setItem(this.w.btoa(window.encodeURIComponent(key)),this.w.btoa(window.encodeURIComponent(value)))
	// }
	
}

/**
 * @param { strinmg } key 传入key 
 * @return { tring } 返回获取存储的值
 */
session.prototype.get = function (key) {

	// console.warn(this.w.decodeURIComponent(this.w.atob(this.sess.getItem(this.w.btoa(key)))))
	if (key && this.sess.getItem(this.w.btoa(key))) {
		// return  this.w.atob(this.sess.getItem(this.w.btoa(key)));
		 return this.w.decodeURIComponent(this.w.atob(this.sess.getItem(this.w.btoa(key))))
	}
}
/**
 * @param {string} key 删除key值
 */
session.prototype.removeKey = function (key) {
	// key && this.sess.removeItem(this.w.btoa(key))
	key && this.sess.removeItem(this.w.decodeURIComponent(this.w.btoa(key)));

}
/**
 * 删除所有
 */
session.prototype.removeAll = function () {
	this.sess.clear();
}

// class
  
// Date.now() - (15*24*60*60*1000)
function FindDom() {
	this.dom = window.document;
	console.log(this.dom)
}
  /**
     * 获取某个id元素
     * @param {string} idName
     */
FindDom.prototype.GetId = function (idName) {
	return document.getElementById(idName)
}
	
 /**
     *设置某个calss样式
     * @param {string}} className
     */
  FindDom.prototype.getClassStyle = function (className) {
    return document.getElementsByClassName(className).style
  },
  /**
     * 设置id样式
     * @param {string} idName
     */
  FindDom.prototype.getIdStyle = function (idName) {
    return document.getElementById(idName).style
  },
  /**
     * 获取多个元素
     * @param {String} All
     */
  FindDom.prototype.getAll = function (All) {
    return document.querySelectorAll(All)
  },
  /** 传入标签或者属性
   * @param {String} leba
   */
  FindDom.prototype.getSelector = function (leba) {
	  return document.querySelector(leba);
  }
	/**
     * 创建节点
     * @param {String} label
     */
 FindDom.prototype.setElement = function (label = 'div') {
    return document.createElement(label)
  },
  /**
     * 获取某一个节点的父级元素
     * @param {object} node
     */
  FindDom.prototype.getFatherNode = function (node) {
    return node.parentNode
  },
  /**
     * 获取某一个节点的子及元素
     * @param {onjct} posterity
     */
  FindDom.prototype.getposterity = function (posterity) {
    return posterity.lastElementChild
  },
  /**
     * 返回某个原数第一个节点
     * @param {object} node
     */
  FindDom.prototype.getfirstChild = function (node) {
    return node.firstChild
  },
  /**
     * 返回某个原数第一个节点
     * @param {object} node
     */
  FindDom.prototype.getfirstElementChild = function (node) {
    return node.firstElementChild
  },
  /**
     * 返回某个原数最后节点
     * @param {object} node
     */
  FindDom.prototype.getlastChild = function (node) {
    return node.lastChild
  },
  /**
     * 在指定元素插入类容
     * @param {object} node 节点
     * @param {string} template  模板类容
     * @param {object | string} place 插入位置
     */
  FindDom.prototype.setnode = function (node, template, place) {
    return node.insertBefore(template, place)
  }	

/*
获取当前地址栏 方法
返回 对应的url 地址数据
*/
 function address_bar_url (){
  this.root = window.location;
  this.Dom = window.document;
  console.log(this)
 }
 address_bar_url.prototype.agreement = function () { // 获取当前协议 
	 return window.location.protocol;
 };
 address_bar_url.prototype.domainName = function () {// 获取当域名
	 return window.location.host;
 }
 address_bar_url.prototype.www = function () {  // 获取当前协议 + 域名
 	return window.location.protocol +"//"+window.location.host;
 };
 address_bar_url.prototype.son = function () { //获取当前子目录
 	return window.location.pathname;
 };
 address_bar_url.prototype.port= function () { //获取当前端口
 	return window.location.port;
 };
 address_bar_url.prototype.parameters = function() { //获取当域名?号后面的参数
 	return 	window.location.search;
 }
 address_bar_url.prototype.url = function () {

 }